package com.project.service.impl;

import com.project.bean.CountBean;
import com.project.bean.MonthCount;
import com.project.mapper.ICountMapper;
import com.project.mapper.IMonthCountMapper;
import com.project.service.ICountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class CountServiceImpl implements ICountService {
@Autowired
private ICountMapper countMapper;
@Autowired
private IMonthCountMapper monthCountMapper;

    @Override
    public Map findCount(LocalDate startDate, LocalDate endDate) {
         List<CountBean> countList1=  countMapper.findCountByType(startDate,endDate);
         List<CountBean> countList2 = countMapper.findCountByMake(startDate,endDate);
        Map<String, List<CountBean>> map =new HashMap<>();
        map.put("count1",countList1);
        map.put("count2",countList2);
        return map;
    }

    @Override
    public List<MonthCount> findMonthCount(Integer year) {
        return  monthCountMapper.findMonthCount(year);
    }

    @Override
    public Integer[] findYear() {
     return monthCountMapper.year();
    }
}
